import 'package:safetymonitor/app/components/custom_app_bar.dart';
import 'package:safetymonitor/app/core/core.dart';
import 'package:safetymonitor/app/core/ext/ext.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'help_controller.dart';

/// 帮助页面
class HelpPage extends StatelessWidget {
  HelpPage({super.key});

  final controller = Get.put(HelpController());

  // 列表页面
  Widget _listView(String title, String rightText, Function() onTap) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 20.w, horizontal: 20.w),
      child: Row(
        children: [
          SizedBox(
            width: 80.w,
            child: Text(
              title,
              style: TextStyle(
                color: Colors.black,
                fontSize: 16.sp,
                fontWeight: FontWeight.w400,
              ),
            ),
          ),
          Expanded(
              child: Container(
            alignment: Alignment.centerRight,
            child: Text(
              rightText,
              style: TextStyle(
                color: const Color(0xFF8791AA),
                fontSize: 14.sp,
                fontWeight: FontWeight.w400,
              ),
            ),
          )),
        ],
      ),
    ).clickOnce(onTap);
  }

  /// 页面分割线
  Widget _getDivider() {
    return Divider(height: 0.5.w, color: Colors.grey[100]).marginSymmetric(horizontal: 10.w);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        titleText: '客服与帮助',
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(height: 10.w, color: Colors.grey[100]),
            _listView('详情地址', '成华区成致路多元总部国际1号2栋', () {
              launchUrlString('geo:latitude,longitude');
            }),
            _getDivider(),
            _listView('联系电话', 'XXXXXXXXXXXXXX', () {
              launchUrlString('tel:XXXXXXXXXXXXXX');
            }),
            _getDivider(),
            _listView('电子邮箱', 'XXXXXXXXXXXXXX', () {
              launchUrlString('mailto:XXXXXXXXXXXXXX');
            }),
            _getDivider(),
          ],
        ),
      ),
    );
  }
}
